package com.bidianying.task;

import java.util.Map;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import redis.clients.jedis.ShardedJedisPool;

import com.bidianying.service.CommonService;
import com.bidianying.service.GewaraService;
import com.bidianying.util.RedisUtils;

@Component 
public class InitDataTask {
	
	@Autowired
	private GewaraService gewaraService;
	@Autowired
	private CommonService commonService;
	@Autowired
	private ShardedJedisPool shardedJedisPool;
	
	//将tMovie_info表中的数据初始化到redis
	@Scheduled(cron = "0 31 10 * * ?") 
	public void job1(){
		System.out.println("initDataTask--job1--start---");
		Map<String,String> movieMap = commonService.getAllMovieForRedis();
		Map<String,String> cinemaMap = commonService.getAllCinemaInfoForRedis();
		RedisUtils.hmset(shardedJedisPool, "movieMap", movieMap, 30*60*60);
		RedisUtils.hmset(shardedJedisPool, "cinemaMap", cinemaMap, 30*60*60);
		System.out.println("initDataTask--job1--end---");
	}
	//比较格瓦拉和卖座的影院，判断是不是同一个影院
	@Scheduled(cron = "0 05 10 * * ?") 
	public void job2(){
		System.out.println("initDataTask--job2--start---");
		//commonService.compareCinemaForMaizuoGewala();
		System.out.println("initDataTask--job2--end---");
	}
	//比较格瓦拉和淘宝的影院，判断是不是同一个影院
	@Scheduled(cron = "0 55 09 * * ?") 
	public void job3(){
		System.out.println("initDataTask--job2--start---");
		//commonService.updateCinemaForTaobao();
		System.out.println("initDataTask--job2--end---");
	}
	
	
	
}
